﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Admin.Domain;

namespace Windows.Admin.Infrastructure.EFCore.Extensions
{
    public static class ChatLinkExtension
    {
        /// <summary>
        /// 获取聊天
        /// </summary>
        /// <param name="query"></param>
        /// <param name="userId1"></param>
        /// <param name="userId2"></param>
        /// <returns></returns>
        public static IQueryable<ChatLink> GetByUserId(this IQueryable<ChatLink> query, long userId)
        {
            return query.Where(x => x.UserId1 == userId || x.UserId2 == userId);
        }
        /// <summary>
        /// 获取聊天
        /// </summary>
        /// <param name="query"></param>
        /// <param name="userId1"></param>
        /// <param name="userId2"></param>
        /// <returns></returns>
        public static IQueryable<ChatLink> GetByTwoUserId(this IQueryable<ChatLink> query, long userId1, long userId2)
        {
            return query.Where(x => (x.UserId1 == userId1 && x.UserId2 == userId2) || (x.UserId1 == userId2 && x.UserId2 == userId1));
        }
    }
}
